const glsl = require('rollup-plugin-glsl');
const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require("@rollup/plugin-commonjs");
const typescript = require('rollup-plugin-typescript2');
const path = require('path');

const workSpaceDir = path.resolve(__dirname, "../");

/**
 * 开发环境配置
 * @type {import('rollup').RollupOptions}
 */
module.exports = {
    input: path.join(workSpaceDir, "src/Main.ts"),

    output: {
        file: path.join(workSpaceDir, "bin/js/bundle.js"),
        format: "iife",
        name: "game",
        sourcemap: true,
        // globals: {
        //     // 将 'tsrpc-browser' 映射到全局变量 '$'
        //     'tsrpc-browser': '__$tsrpc__'
        // }
    },

    // external: id => {
    //     return /node_modules/.test(id);
    // },

    plugins: [

        typescript({
            tsconfig: path.join(workSpaceDir, "tsconfig.json"),
            tsconfigOverride: { compilerOptions: { removeComments: true } },
            check: true,
            exclude: /node_modules/
        }),

        glsl({
            //By default, everything gets included
            include: /.*(.glsl|.vs|.fs)$/,
            sourceMap: true,
            compress: false
        }),
        resolve(),
        commonjs()

    ]
}


